﻿using System;
using SchemaGen.Xsd;

namespace SchemaGen.Attributes
{
    [AttributeUsage(AttributeTargets.All, Inherited = true, AllowMultiple = true)]
    public sealed class XmlComplexTypeAttribute : Attribute
    {
        public string Name { get; private set; }

        /// <summary>
        /// Use this to inherit from another complex type.
        /// </summary>
        public string Extends { get; set; }

        /// <summary>
        /// Default sequence is "All"
        /// </summary>
        public SequenceIndicator SequenceIndicator { get; set; }

        public XmlComplexTypeAttribute(string name)
        {
            if (!Globals.XML_NAME_REGEX.IsMatch(name)) throw new ArgumentException(name + " is not a valid XML name", "name");
            Name = name;
            SequenceIndicator = SequenceIndicator.All;
        }
    }
}
